﻿namespace QLPhongKham.UC
{
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Mask;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using QLPhongKham.Access;
    using QLPhongKham.Access.BenhNhan;
    using QLPhongKham.Access.Duoc;
    using QLPhongKham.BaseClass.BenhNhan;
    using QLPhongKham.BaseClass.Duoc;
    using QLPhongKham.Report;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using UserControls;

    public class ucbn_captoathuocmuangoai : XtraUserControl
    {
        private long _idql;
        private int _iiddangnhap;
        private int _loaibn;
        private DToaThuoc _toathuoc;
        private General _xuli;
        private SimpleButton btnboqua;
        private SimpleButton btnhuy;
        private SimpleButton btnin;
        private SimpleButton btnketthuc;
        private SimpleButton btnluu;
        private SimpleButton btnmoi;
        private SimpleButton btnsua;
        private SimpleButton btnthemcachdung;
        private SimpleButton btnthemduocpham;
        private SimpleButton btnxoa;
        private LookUpEdit cbbphong;
        private IContainer components;
        private ctrdanhsach ctrdanhsach_cachdung;
        private ctrdanhsach ctrdanhsach_vp;
        private DateEdit datechidinh;
        private GridControl gridds;
        private GridColumn gridds_cachdung;
        private GridColumn gridds_dvt;
        private GridColumn gridds_ghichu;
        private GridColumn gridds_hamluong;
        private GridColumn gridds_id;
        private GridColumn gridds_idtoathuocct;
        private GridColumn gridds_ma;
        private GridColumn gridds_slchieu;
        private GridColumn gridds_slsang;
        private GridColumn gridds_sltoi;
        private GridColumn gridds_sltrua;
        private GridColumn gridds_soluong;
        private GridColumn gridds_songay;
        private GridColumn gridds_ten;
        private GridColumn gridds_tenhoatchat;
        private GridView gridView1;
        private Label label1;
        private Label label10;
        private Label label11;
        private Label label12;
        private Label label13;
        private Label label14;
        private Label label15;
        private Label label16;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        private Label label9;
        private Label lblmaso;
        private NumericUpDown numsongay;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private RepositoryItemTextEdit repositoryItemTextEdit2;
        private UCTextBoxNumeric tbnumslchieu;
        private UCTextBoxNumeric tbnumslsang;
        private UCTextBoxNumeric tbnumsltoi;
        private UCTextBoxNumeric tbnumsltrua;
        private TextEdit txtcachdung;
        private TextEdit txtchandoan;
        private TextEdit txtdvt;
        private TextEdit txthamluong;
        private TextEdit txthoten;
        private TextEdit txtma;
        private TextEdit txtmabn;
        private TextEdit txtnguoinhap;
        private TextEdit txtsoluong;
        private TextEdit txtten;
        private TextEdit txttenhoatchat;

        public ucbn_captoathuocmuangoai()
        {
            this._loaibn = 1;
            this._idql = 0L;
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = new General();
        }

        public ucbn_captoathuocmuangoai(General xuli, int iddangnhap)
        {
            this._loaibn = 1;
            this._idql = 0L;
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._iiddangnhap = iddangnhap;
        }

        public ucbn_captoathuocmuangoai(General xuli, long idql, int loaibn, int iddangnhap)
        {
            this._loaibn = 1;
            this._idql = 0L;
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._idql = idql;
            this._loaibn = loaibn;
            this._iiddangnhap = iddangnhap;
        }

        private void btnboqua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(false);
        }

        private void btnhuy_Click(object sender, EventArgs e)
        {
            if (((this.txthoten.Tag.ToString() != "") && !(this.txthoten.Tag.ToString() == "0")) && (MessageBox.Show("Bạn c\x00f3 chắc chắn muốn hủy toa thuốc n\x00e0y kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes))
            {
                if (this._toathuoc.f_huy_toathuoc_ngoaivien(long.Parse(this.txthoten.Tag.ToString())))
                {
                    MessageBox.Show("Đ\x00e3 hủy th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                    this.f_setcontrol_toathuoc(this._idql);
                    if (this.txthoten.Tag.ToString() == "0")
                    {
                        this.f_loadData_thongtinloaibn(this._loaibn);
                    }
                    this.f_loaddata_toathuocct(long.Parse(this.txthoten.Tag.ToString()));
                    this.btnboqua_Click(null, null);
                    this.f_loadinfo_chidinhchitiet(0);
                }
                else
                {
                    MessageBox.Show("Hủy kh\x00f4ng th\x00e0nh c\x00f4ng.Vui l\x00f2ng kiểm tra lại.", "Th\x00f4ng b\x00e1o");
                }
            }
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            dtoBNThongTinBN nbn = new dtoBNThongTinBN {
                MABN = this.txtmabn.Text
            };
            nbn.Load();
            DataTable table2 = ((DataTable) this.gridds.DataSource).Copy();
            table2.Columns.Add("hoten");
            table2.Columns.Add("namsinh");
            table2.Columns.Add("phai");
            table2.Columns.Add("diachi");
            table2.Columns.Add("tenkp");
            table2.Columns.Add("makp");
            table2.Columns.Add("chandoan");
            table2.Columns.Add("nguoinhap");
            for (int i = 0; i < table2.Rows.Count; i++)
            {
                table2.Rows[i]["hoten"] = nbn.HOTEN;
                table2.Rows[i]["namsinh"] = nbn.NAMSINH.ToString();
                table2.Rows[i]["phai"] = (nbn.IDGIOITINH == 0) ? "Nam" : "Nữ";
                table2.Rows[i]["diachi"] = nbn.DIACHI;
                table2.Rows[i]["tenkp"] = this.cbbphong.Text;
                table2.Rows[i]["makp"] = this.cbbphong.EditValue.ToString();
                table2.Rows[i]["chandoan"] = this.txtchandoan.Text;
                table2.Rows[i]["nguoinhap"] = this.txtnguoinhap.Text;
            }
            DataSet data = new DataSet();
            data.Tables.Add(table2.Copy());
            data.WriteXml("dataxml//toathuoc_ngoaivien.xml", XmlWriteMode.WriteSchema);
            new XtraReport1().f_load(data, "bn_intoathuoc_ngoaivien.repx");
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                try
                {
                    XtraUserControl control2 = (XtraUserControl) base.Parent;
                    control2.Controls.Remove(this);
                }
                catch
                {
                }
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            if (this.f_kiemtra_luu())
            {
                dtoDToaThuocNgoaiVienCT nct = new dtoDToaThuocNgoaiVienCT(this._xuli.pConFigData);
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                dataSource.AcceptChanges();
                dtoDToaThuocNgoaiVienCT[] chitiet = new dtoDToaThuocNgoaiVienCT[dataSource.Rows.Count];
                for (int i = 0; i < dataSource.Rows.Count; i++)
                {
                    nct = new dtoDToaThuocNgoaiVienCT(this._xuli.pConFigData) {
                        pIDDANGNHAP = this._iiddangnhap,
                        pIDDP = int.Parse(dataSource.Rows[i][this.gridds_id.FieldName].ToString()),
                        pIDTOATHUOC = long.Parse(this.txthoten.Tag.ToString()),
                        pSOLUONG = decimal.Parse(dataSource.Rows[i][this.gridds_soluong.FieldName].ToString()),
                        pSOLUONGCHIEU = decimal.Parse(dataSource.Rows[i][this.gridds_slchieu.FieldName].ToString()),
                        pSOLUONGSANG = decimal.Parse(dataSource.Rows[i][this.gridds_slsang.FieldName].ToString()),
                        pSOLUONGTOI = decimal.Parse(dataSource.Rows[i][this.gridds_sltoi.FieldName].ToString()),
                        pSOLUONGTRUA = decimal.Parse(dataSource.Rows[i][this.gridds_sltrua.FieldName].ToString())
                    };
                    try
                    {
                        nct.pSONGAY = Convert.ToInt16(dataSource.Rows[i][this.gridds_songay.FieldName].ToString());
                    }
                    catch
                    {
                    }
                    nct.pCACHDUNG = dataSource.Rows[i][this.gridds_cachdung.FieldName].ToString();
                    nct.pTENMAYTINH = Environment.MachineName;
                    chitiet[i] = nct;
                }
                dtoDToaThuocNgoaiVien toaThuoc = new dtoDToaThuocNgoaiVien(this._xuli.pConFigData) {
                    pCHANDOAN = this.txtchandoan.Text,
                    pID = long.Parse(this.txthoten.Tag.ToString()),
                    pIDDANGNHAP = this._iiddangnhap,
                    pIDPHONG = int.Parse(this.cbbphong.EditValue.ToString()),
                    pIDQL = this._idql,
                    pMABN = this.txtmabn.Text,
                    pNGAY = this.datechidinh.Text,
                    pTENMAYTINH = Environment.MachineName
                };
                DToaThuoc thuoc = new DToaThuoc(this._xuli.pConFigData);
                if (toaThuoc.pID == 0L)
                {
                    this.txthoten.Tag = thuoc.f_insert_toathuoc_ngoaivien(toaThuoc, chitiet).ToString();
                    if (this.txthoten.Tag.ToString() == "0")
                    {
                        MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin toa thuốc.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                else
                {
                    this.txthoten.Tag = thuoc.f_update_toathuoc_ngoaivien(toaThuoc, chitiet).ToString();
                    if (this.txthoten.Tag.ToString() == "0")
                    {
                        MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin toa thuốc.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                this.f_setcontrol_toathuoc(this._idql);
                this.f_loaddata_toathuocct(long.Parse(this.txthoten.Tag.ToString()));
                this.f_Control_enable(false);
            }
        }

        private void btnmoi_Click(object sender, EventArgs e)
        {
            this.f_Add_ChiTiet();
            this.f_Loadcontrol_dmvp(0L, "", "", "", "", "");
            base.ActiveControl = this.txtma;
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.txtma.Focus();
        }

        private void btnthemcachdung_Click(object sender, EventArgs e)
        {
            ucd_dmcachdung _dmcachdung = new ucd_dmcachdung(this._xuli.pConFigData, this._iiddangnhap);
            base.Controls.Add(_dmcachdung);
            _dmcachdung.Location = new Point(0, 0);
            _dmcachdung.Width = base.Width;
            _dmcachdung.Height = base.Height;
            _dmcachdung.Show();
            _dmcachdung.BringToFront();
        }

        private void btnthemduocpham_Click(object sender, EventArgs e)
        {
            ucd_dmduocpham _dmduocpham = new ucd_dmduocpham();
            base.Controls.Add(_dmduocpham);
            _dmduocpham.Location = new Point(0, 0);
            _dmduocpham.Width = base.Width;
            _dmduocpham.Height = base.Height;
            _dmduocpham.Show();
            _dmduocpham.BringToFront();
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            try
            {
                this.gridView1.DeleteSelectedRows();
            }
            catch
            {
            }
        }

        private void ctrdanhsach_cachdung_Validated(object sender, EventArgs e)
        {
            try
            {
                DataTable dongHienTai = this.ctrdanhsach_cachdung.DongHienTai;
                this.f_SetControl_dmcachdung(long.Parse(dongHienTai.Rows[0]["id"].ToString()), this.txtcachdung.Text);
            }
            catch
            {
            }
        }

        private void ctrdanhsach_vp_Validated(object sender, EventArgs e)
        {
            try
            {
                DataTable dongHienTai = this.ctrdanhsach_vp.DongHienTai;
                this.f_SetControl_dmsanpham(long.Parse(dongHienTai.Rows[0]["id"].ToString()));
            }
            catch
            {
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_Add_ChiTiet()
        {
            if ((this.txtma.Tag != null) && (this.txtma.Tag.ToString() != "0"))
            {
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                DataRow row = dataSource.NewRow();
                row[this.gridds_idtoathuocct.FieldName] = 0;
                row[this.gridds_ma.FieldName] = this.txtma.Text;
                row[this.gridds_ten.FieldName] = this.txtten.Text;
                row[this.gridds_dvt.FieldName] = this.txtdvt.Text;
                row[this.gridds_id.FieldName] = this.txtma.Tag.ToString();
                row[this.gridds_soluong.FieldName] = this.txtsoluong.EditValue;
                row[this.gridds_slsang.FieldName] = this.tbnumslsang.Values;
                row[this.gridds_sltrua.FieldName] = this.tbnumsltrua.Values;
                row[this.gridds_slchieu.FieldName] = this.tbnumslchieu.Values;
                row[this.gridds_sltoi.FieldName] = this.tbnumsltoi.Values;
                row[this.gridds_songay.FieldName] = this.numsongay.Value;
                row[this.gridds_cachdung.FieldName] = this.txtcachdung.Text;
                DataTable table2 = (DataTable) this.gridds.DataSource;
                table2.AcceptChanges();
                DataRow[] rowArray = table2.Select(this.gridds_id.FieldName + "=" + row[this.gridds_id.FieldName].ToString());
                if (rowArray.Length > 0)
                {
                    if (MessageBox.Show("T\x00ean dược phẩm '" + row[this.gridds_ten.FieldName].ToString().ToUpper() + "' đ\x00e3 tồn tại.\nBạn c\x00f3 muốn cập nhật lại th\x00f4ng tin dược phẩm n\x00e0y kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        rowArray[0][this.gridds_soluong.FieldName] = this.txtsoluong.EditValue;
                        rowArray[0][this.gridds_slsang.FieldName] = this.tbnumslsang.Values;
                        rowArray[0][this.gridds_sltrua.FieldName] = this.tbnumsltrua.Values;
                        rowArray[0][this.gridds_slchieu.FieldName] = this.tbnumslchieu.Values;
                        rowArray[0][this.gridds_sltoi.FieldName] = this.tbnumsltoi.Values;
                        rowArray[0][this.gridds_songay.FieldName] = this.numsongay.Value;
                        rowArray[0][this.gridds_cachdung.FieldName] = this.txtcachdung.Text;
                        dataSource = table2.Copy();
                    }
                }
                else
                {
                    dataSource.Rows.Add(row);
                }
                this.gridds.DataSource = dataSource;
            }
        }

        private void f_Control_enable(bool chophep)
        {
            this.btnluu.Enabled = this.btnboqua.Enabled = this.btnmoi.Enabled = this.btnxoa.Enabled = chophep;
            this.btnsua.Enabled = this.btnketthuc.Enabled = this.btnhuy.Enabled = this.btnin.Enabled = !chophep;
        }

        private bool f_kiemtra_luu()
        {
            DataTable dataSource = (DataTable) this.gridds.DataSource;
            if (dataSource.Rows.Count == 0)
            {
                MessageBox.Show("Chưa nhập chi tiết toa thuốc.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            return true;
        }

        private void f_load_khoaphong()
        {
            try
            {
                this.cbbphong.Properties.DataSource = new dtoBNDMPhong(this._xuli.pConFigData).LoadAll();
                this.cbbphong.Properties.DisplayMember = "ten";
                this.cbbphong.Properties.ValueMember = "id";
                this.cbbphong.ItemIndex = 0;
            }
            catch
            {
            }
        }

        private void f_Loadcontrol_chidinhchitiet(long id, decimal soluong, decimal slsang, decimal sltrua, decimal slchieu, decimal sltoi, decimal songay, string cachdung)
        {
            this.lblmaso.Tag = id.ToString();
            this.txtsoluong.EditValue = soluong;
            this.tbnumslsang.Values = slsang;
            this.tbnumsltrua.Values = sltrua;
            this.tbnumslchieu.Values = slchieu;
            this.tbnumsltoi.Values = sltoi;
            this.numsongay.Value = songay;
            this.txtcachdung.Text = cachdung;
        }

        private void f_Loadcontrol_dmcachdung(long id, string tencachdung, decimal soluong)
        {
            this.txtcachdung.Tag = id;
            this.txtcachdung.Text = tencachdung;
            this.txtsoluong.EditValue = soluong;
            this.txtsoluong.Tag = soluong;
        }

        private void f_Loadcontrol_dmvp(long id, string ma, string ten, string tenhoatchat, string dvt, string hamluong)
        {
            this.txtma.Text = ma;
            this.txtma.Tag = id.ToString();
            this.txtten.Text = ten;
            this.txtdvt.Text = dvt;
            this.txthamluong.Text = hamluong;
            this.txttenhoatchat.Text = tenhoatchat;
        }

        private void f_loadControl_thongtinbenhnhan(long idql, long idtoathuoc, string mabn, string hoten, int idphong, string ngay, string chandoan, string tennguoinhap)
        {
            this.txtmabn.Tag = idql.ToString();
            this.txtmabn.Text = mabn;
            this.txthoten.Tag = idtoathuoc.ToString();
            this.txthoten.Text = hoten;
            this.cbbphong.EditValue = idphong;
            try
            {
                this.datechidinh.EditValue = new DateTime(int.Parse(ngay.Substring(6, 4)), int.Parse(ngay.Substring(3, 2)), int.Parse(ngay.Substring(0, 2)), int.Parse(ngay.Substring(11, 2)), int.Parse(ngay.Substring(14, 2)), 0);
            }
            catch
            {
            }
            this.txtchandoan.Text = chandoan;
            this.txtnguoinhap.Text = tennguoinhap;
        }

        private void f_Loaddata_cachdung()
        {
            try
            {
                this.ctrdanhsach_cachdung.SetDataSource = new dtoDDMCachDung(this._xuli.pConFigData).LoadAll();
                this.ctrdanhsach_cachdung.DanhSachCotHienThi = "ten,soluong";
            }
            catch
            {
            }
        }

        private void f_Loaddata_dmduocpham()
        {
            try
            {
                this.ctrdanhsach_vp.SetDataSource = new dtoDDMDuocPham(this._xuli.pConFigData).LoadAll();
                this.ctrdanhsach_vp.DanhSachCotHienThi = "ma,ten,dvt";
            }
            catch
            {
            }
        }

        private void f_loadData_thongtinloaibn(int loaibn)
        {
            try
            {
                DataTable table = new DataTable();
                try
                {
                    table = new BNTiepDon(this._xuli.pConFigData).f_loaddata_bntiepdon(this._idql);
                    this.f_loadControl_thongtinbenhnhan(long.Parse(table.Rows[0]["idql"].ToString()), 0L, table.Rows[0]["mabn"].ToString(), table.Rows[0]["hoten"].ToString(), int.Parse(table.Rows[0]["idphong"].ToString()), table.Rows[0]["ngay"].ToString(), "", "");
                }
                catch
                {
                }
                try
                {
                    table = new BNKhamBenh(this._xuli.pConFigData).f_loaddata_bnkhambenh(this._idql);
                    this.f_loadControl_thongtinbenhnhan(long.Parse(table.Rows[0]["idql"].ToString()), 0L, table.Rows[0]["mabn"].ToString(), table.Rows[0]["hoten"].ToString(), int.Parse(table.Rows[0]["idphong"].ToString()), table.Rows[0]["ngay"].ToString(), table.Rows[0]["chandoan"].ToString(), "");
                }
                catch
                {
                }
            }
            catch
            {
            }
        }

        private void f_loaddata_toathuocct(long idtoathuoc)
        {
            DataTable table = this._toathuoc.f_loaddata_toathuoc_ngoaivienct(idtoathuoc, 0L, "");
            this.gridds.DataSource = table;
        }

        private void f_loadinfo_chidinhchitiet(int indexrow)
        {
            try
            {
                this.f_Loadcontrol_dmvp(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_id).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ma).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_ten).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_tenhoatchat).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_dvt).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_hamluong).ToString());
                this.f_Loadcontrol_chidinhchitiet(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_idtoathuocct).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_soluong).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_slsang).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_sltrua).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_slchieu).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_sltoi).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_songay).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_cachdung).ToString());
            }
            catch
            {
            }
        }

        private void f_SetControl_dmcachdung(long id, string cachdung)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_cachdung.SetDataSource.Select("id=" + id.ToString());
                this.f_Loadcontrol_dmcachdung(id, rowArray[0]["ten"].ToString(), decimal.Parse(rowArray[0]["soluong"].ToString()));
            }
            catch
            {
                this.f_Loadcontrol_dmcachdung(0L, cachdung, 0M);
            }
        }

        private void f_SetControl_dmsanpham(long idvp)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("id=" + idvp.ToString());
                this.f_Loadcontrol_dmvp(idvp, rowArray[0]["ma"].ToString(), rowArray[0]["ten"].ToString(), rowArray[0]["tenhoatchat"].ToString(), rowArray[0]["dvt"].ToString(), rowArray[0]["hamluong"].ToString());
            }
            catch
            {
                this.f_Loadcontrol_dmvp(0L, "", "", "", "", "");
            }
        }

        private void f_setcontrol_toathuoc(long idql)
        {
            DataTable table = this._toathuoc.f_loaddata_toathuoc_ngoaivien(idql);
            try
            {
                this.f_loadControl_thongtinbenhnhan(long.Parse(table.Rows[0]["idql"].ToString()), long.Parse(table.Rows[0]["id"].ToString()), table.Rows[0]["mabn"].ToString(), table.Rows[0]["hoten"].ToString(), int.Parse(table.Rows[0]["idphong"].ToString()), table.Rows[0]["ngay"].ToString(), table.Rows[0]["chandoan"].ToString(), table.Rows[0]["tennguoidangnhap"].ToString());
            }
            catch
            {
                this.f_loadControl_thongtinbenhnhan(0L, 0L, "", "", 0, DateTime.Now.ToString("dd/MM/yyyy HH:mm"), "", "");
            }
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            int indexrow = 0;
            try
            {
                indexrow = this.gridView1.GetSelectedRows()[0];
                this.f_loadinfo_chidinhchitiet(indexrow);
            }
            catch
            {
            }
        }

        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucbn_captoathuocmuangoai));
            StyleFormatCondition condition = new StyleFormatCondition();
            this.repositoryItemTextEdit2 = new RepositoryItemTextEdit();
            this.lblmaso = new Label();
            this.txtma = new TextEdit();
            this.label3 = new Label();
            this.txtten = new TextEdit();
            this.txtdvt = new TextEdit();
            this.label5 = new Label();
            this.btnmoi = new SimpleButton();
            this.btnluu = new SimpleButton();
            this.btnsua = new SimpleButton();
            this.btnxoa = new SimpleButton();
            this.btnketthuc = new SimpleButton();
            this.gridView1 = new GridView();
            this.gridds_ma = new GridColumn();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.gridds_ten = new GridColumn();
            this.gridds_dvt = new GridColumn();
            this.gridds_id = new GridColumn();
            this.gridds_soluong = new GridColumn();
            this.gridds_ghichu = new GridColumn();
            this.gridds_idtoathuocct = new GridColumn();
            this.gridds_tenhoatchat = new GridColumn();
            this.gridds_slsang = new GridColumn();
            this.gridds_sltrua = new GridColumn();
            this.gridds_slchieu = new GridColumn();
            this.gridds_sltoi = new GridColumn();
            this.gridds_cachdung = new GridColumn();
            this.gridds_songay = new GridColumn();
            this.gridds_hamluong = new GridColumn();
            this.gridds = new GridControl();
            this.btnboqua = new SimpleButton();
            this.label1 = new Label();
            this.txtmabn = new TextEdit();
            this.label6 = new Label();
            this.txthoten = new TextEdit();
            this.label8 = new Label();
            this.datechidinh = new DateEdit();
            this.ctrdanhsach_vp = new ctrdanhsach();
            this.label9 = new Label();
            this.cbbphong = new LookUpEdit();
            this.label10 = new Label();
            this.txtchandoan = new TextEdit();
            this.label11 = new Label();
            this.txtnguoinhap = new TextEdit();
            this.txttenhoatchat = new TextEdit();
            this.label2 = new Label();
            this.label4 = new Label();
            this.label7 = new Label();
            this.label12 = new Label();
            this.numsongay = new NumericUpDown();
            this.label13 = new Label();
            this.label14 = new Label();
            this.label16 = new Label();
            this.txtcachdung = new TextEdit();
            this.tbnumslsang = new UCTextBoxNumeric();
            this.tbnumsltrua = new UCTextBoxNumeric();
            this.tbnumslchieu = new UCTextBoxNumeric();
            this.tbnumsltoi = new UCTextBoxNumeric();
            this.btnin = new SimpleButton();
            this.btnhuy = new SimpleButton();
            this.label15 = new Label();
            this.txthamluong = new TextEdit();
            this.btnthemduocpham = new SimpleButton();
            this.ctrdanhsach_cachdung = new ctrdanhsach();
            this.btnthemcachdung = new SimpleButton();
            this.txtsoluong = new TextEdit();
            this.repositoryItemTextEdit2.BeginInit();
            this.txtma.Properties.BeginInit();
            this.txtten.Properties.BeginInit();
            this.txtdvt.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            this.gridds.BeginInit();
            this.txtmabn.Properties.BeginInit();
            this.txthoten.Properties.BeginInit();
            this.datechidinh.Properties.VistaTimeProperties.BeginInit();
            this.datechidinh.Properties.BeginInit();
            this.cbbphong.Properties.BeginInit();
            this.txtchandoan.Properties.BeginInit();
            this.txtnguoinhap.Properties.BeginInit();
            this.txttenhoatchat.Properties.BeginInit();
            this.numsongay.BeginInit();
            this.txtcachdung.Properties.BeginInit();
            this.txthamluong.Properties.BeginInit();
            this.txtsoluong.Properties.BeginInit();
            base.SuspendLayout();
            this.repositoryItemTextEdit2.AutoHeight = false;
            this.repositoryItemTextEdit2.DisplayFormat.FormatString = "n0";
            this.repositoryItemTextEdit2.DisplayFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.EditFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.Mask.EditMask = "n0";
            this.repositoryItemTextEdit2.Mask.MaskType = MaskType.Numeric;
            this.repositoryItemTextEdit2.Name = "repositoryItemTextEdit2";
            this.lblmaso.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.lblmaso.Font = new Font("Tahoma", 10f);
            this.lblmaso.Location = new Point(5, 0x144);
            this.lblmaso.Name = "lblmaso";
            this.lblmaso.Size = new Size(0x4b, 0x13);
            this.lblmaso.TabIndex = 2;
            this.lblmaso.Text = "M\x00e3 số:";
            this.lblmaso.TextAlign = ContentAlignment.TopRight;
            this.txtma.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtma.Location = new Point(0x4a, 0x143);
            this.txtma.Name = "txtma";
            this.txtma.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtma.Size = new Size(0x6a, 20);
            this.txtma.TabIndex = 6;
            this.txtma.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtma.Validated += new EventHandler(this.txtma_Validated);
            this.label3.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label3.Font = new Font("Tahoma", 10f);
            this.label3.Location = new Point(170, 0x144);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x3b, 0x13);
            this.label3.TabIndex = 2;
            this.label3.Text = "T\x00ean:";
            this.label3.TextAlign = ContentAlignment.TopRight;
            this.txtten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtten.Location = new Point(0xe5, 0x143);
            this.txtten.Name = "txtten";
            this.txtten.Size = new Size(0xaf, 20);
            this.txtten.TabIndex = 7;
            this.txtten.TextChanged += new EventHandler(this.txtten_TextChanged);
            this.txtten.Enter += new EventHandler(this.txtten_Enter);
            this.txtten.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txtten.Validated += new EventHandler(this.txtten_Validated);
            this.txtdvt.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtdvt.EditValue = "";
            this.txtdvt.Enabled = false;
            this.txtdvt.Location = new Point(0x314, 0x15d);
            this.txtdvt.Name = "txtdvt";
            this.txtdvt.Size = new Size(40, 20);
            this.txtdvt.TabIndex = 0x10;
            this.txtdvt.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label5.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label5.Font = new Font("Tahoma", 10f);
            this.label5.Location = new Point(0x11, 0x110);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x41, 0x13);
            this.label5.TabIndex = 2;
            this.label5.Text = "S\x00e1ng:";
            this.label5.TextAlign = ContentAlignment.TopRight;
            this.label5.Visible = false;
            this.btnmoi.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnmoi.Appearance.Options.UseTextOptions = true;
            this.btnmoi.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnmoi.Image = Properties.Resources.imgnew;// (Image)manager.GetObject("btnmoi.Image");
            this.btnmoi.Location = new Point(4, 0x185);
            this.btnmoi.Name = "btnmoi";
            this.btnmoi.Size = new Size(0x4b, 0x17);
            this.btnmoi.TabIndex = 0x13;
            this.btnmoi.Text = " &Th\x00eam [F2]";
            this.btnmoi.Click += new EventHandler(this.btnmoi_Click);
            this.btnluu.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnluu.Appearance.Options.UseTextOptions = true;
            this.btnluu.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnluu.Image = Properties.Resources.imgsave;// (Image)manager.GetObject("btnluu.Image");
            this.btnluu.Location = new Point(0x55, 0x185);
            this.btnluu.Name = "btnluu";
            this.btnluu.Size = new Size(0x4b, 0x17);
            this.btnluu.TabIndex = 20;
            this.btnluu.Text = " &Lưu [F5]";
            this.btnluu.Click += new EventHandler(this.btnluu_Click);
            this.btnsua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnsua.Appearance.Options.UseTextOptions = true;
            this.btnsua.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnsua.Image = Properties.Resources.imgedit;// (Image)manager.GetObject("btnsua.Image");
            this.btnsua.Location = new Point(0xa4, 0x185);
            this.btnsua.Name = "btnsua";
            this.btnsua.Size = new Size(0x4b, 0x17);
            this.btnsua.TabIndex = 0x15;
            this.btnsua.Text = " &Sửa [F3]";
            this.btnsua.Click += new EventHandler(this.btnsua_Click);
            this.btnxoa.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnxoa.Image = Properties.Resources.imgdelete;// (Image)manager.GetObject("btnxoa.Image");
            this.btnxoa.Location = new Point(0x14e, 0x185);
            this.btnxoa.Name = "btnxoa";
            this.btnxoa.Size = new Size(0x4b, 0x17);
            this.btnxoa.TabIndex = 0x17;
            this.btnxoa.Text = " &X\x00f3a";
            this.btnxoa.Click += new EventHandler(this.btnxoa_Click);
            this.btnketthuc.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnketthuc.Appearance.Options.UseTextOptions = true;
            this.btnketthuc.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnketthuc.Image = Properties.Resources.imgclose;// (Image)manager.GetObject("btnketthuc.Image");
            this.btnketthuc.Location = new Point(0x2d6, 0x185);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new Size(0x65, 0x17);
            this.btnketthuc.TabIndex = 0x19;
            this.btnketthuc.Text = " &Kết th\x00fac [F12]";
            this.btnketthuc.Click += new EventHandler(this.btnketthuc_Click);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x7a, 0x72, 0x71);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(200, 0xc0, 0x9d);
            this.gridView1.Appearance.FocusedRow.BorderColor = Color.FromArgb(0xe2, 0xdb, 0xbc);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf6, 0xf2, 0xd5);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.Black;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(0xfb, 0xfc, 0xf7);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x94, 0x94, 0x94);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0xdd, 0xd7, 0xbc);
            this.gridView1.Appearance.SelectedRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { this.gridds_ma, this.gridds_ten, this.gridds_dvt, this.gridds_id, this.gridds_soluong, this.gridds_ghichu, this.gridds_idtoathuocct, this.gridds_tenhoatchat, this.gridds_slsang, this.gridds_sltrua, this.gridds_slchieu, this.gridds_sltoi, this.gridds_cachdung, this.gridds_songay, this.gridds_hamluong });
            condition.Appearance.ForeColor = Color.Red;
            condition.Appearance.Options.UseForeColor = true;
            condition.Condition = FormatConditionEnum.Between;
            condition.Value1 = "0";
            condition.Value2 = "0";
            this.gridView1.FormatConditions.AddRange(new StyleFormatCondition[] { condition });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsBehavior.AllowAddRows = DefaultBoolean.True;
            this.gridView1.OptionsBehavior.AllowDeleteRows = DefaultBoolean.False;
            this.gridView1.OptionsBehavior.ReadOnly = true;
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.RowCellStyle += new RowCellStyleEventHandler(this.gridView1_RowCellStyle);
            this.gridView1.CustomSummaryCalculate += new CustomSummaryEventHandler(this.gridView1_CustomSummaryCalculate);
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridView1.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.gridds_ma.Caption = "M\x00e3 số";
            this.gridds_ma.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ma.FieldName = "mavp";
            this.gridds_ma.Name = "gridds_ma";
            this.gridds_ma.OptionsColumn.AllowEdit = false;
            this.gridds_ma.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "Tổng cộng={0:n0}") });
            this.gridds_ma.Visible = true;
            this.gridds_ma.VisibleIndex = 0;
            this.gridds_ma.Width = 0x5b;
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.repositoryItemTextEdit1.ReadOnly = true;
            this.gridds_ten.Caption = "T\x00ean dược phẩm";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ten.FieldName = "tenvp";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 1;
            this.gridds_ten.Width = 0x12e;
            this.gridds_dvt.Caption = "ĐVT";
            this.gridds_dvt.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_dvt.FieldName = "dvt";
            this.gridds_dvt.Name = "gridds_dvt";
            this.gridds_dvt.OptionsColumn.AllowEdit = false;
            this.gridds_dvt.Visible = true;
            this.gridds_dvt.VisibleIndex = 2;
            this.gridds_dvt.Width = 0x23;
            this.gridds_id.Caption = "id";
            this.gridds_id.FieldName = "idvp";
            this.gridds_id.Name = "gridds_id";
            this.gridds_soluong.Caption = "SL";
            this.gridds_soluong.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_soluong.FieldName = "soluong";
            this.gridds_soluong.Name = "gridds_soluong";
            this.gridds_soluong.Visible = true;
            this.gridds_soluong.VisibleIndex = 3;
            this.gridds_soluong.Width = 0x19;
            this.gridds_ghichu.Caption = "Ghi ch\x00fa";
            this.gridds_ghichu.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ghichu.FieldName = "ghichu";
            this.gridds_ghichu.Name = "gridds_ghichu";
            this.gridds_ghichu.OptionsColumn.AllowEdit = false;
            this.gridds_ghichu.Visible = true;
            this.gridds_ghichu.VisibleIndex = 4;
            this.gridds_ghichu.Width = 0x8e;
            this.gridds_idtoathuocct.Caption = "idtoathuocct";
            this.gridds_idtoathuocct.FieldName = "id";
            this.gridds_idtoathuocct.Name = "gridds_idtoathuocct";
            this.gridds_tenhoatchat.Caption = "tenhoatchat";
            this.gridds_tenhoatchat.FieldName = "tenhoatchat";
            this.gridds_tenhoatchat.Name = "gridds_tenhoatchat";
            this.gridds_slsang.Caption = "slsang";
            this.gridds_slsang.FieldName = "slsang";
            this.gridds_slsang.Name = "gridds_slsang";
            this.gridds_sltrua.Caption = "sltrua";
            this.gridds_sltrua.FieldName = "sltrua";
            this.gridds_sltrua.Name = "gridds_sltrua";
            this.gridds_slchieu.Caption = "slchieu";
            this.gridds_slchieu.FieldName = "slchieu";
            this.gridds_slchieu.Name = "gridds_slchieu";
            this.gridds_sltoi.Caption = "sltoi";
            this.gridds_sltoi.FieldName = "sltoi";
            this.gridds_sltoi.Name = "gridds_sltoi";
            this.gridds_cachdung.Caption = "cachdung";
            this.gridds_cachdung.FieldName = "cachdung";
            this.gridds_cachdung.Name = "gridds_cachdung";
            this.gridds_songay.Caption = "songay";
            this.gridds_songay.FieldName = "songay";
            this.gridds_songay.Name = "gridds_songay";
            this.gridds_hamluong.Caption = "H\x00e0m lượng";
            this.gridds_hamluong.FieldName = "hamluong";
            this.gridds_hamluong.Name = "gridds_hamluong";
            this.gridds_hamluong.Visible = true;
            this.gridds_hamluong.VisibleIndex = 5;
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(3, 0x40);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemTextEdit1, this.repositoryItemTextEdit2 });
            this.gridds.Size = new Size(0x339, 0xfd);
            this.gridds.TabIndex = 0x18;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.gridds.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.btnboqua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnboqua.Image = Properties.Resources.imgundo;// (Image)manager.GetObject("btnboqua.Image");
            this.btnboqua.Location = new Point(0xf3, 0x185);
            this.btnboqua.Name = "btnboqua";
            this.btnboqua.Size = new Size(0x57, 0x17);
            this.btnboqua.TabIndex = 0x16;
            this.btnboqua.Text = " &Bỏ qua [F4]";
            this.btnboqua.Click += new EventHandler(this.btnboqua_Click);
            this.label1.Font = new Font("Tahoma", 10f);
            this.label1.Location = new Point(6, 13);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x3d, 0x13);
            this.label1.TabIndex = 2;
            this.label1.Text = "M\x00e3 BN:";
            this.label1.TextAlign = ContentAlignment.TopRight;
            this.txtmabn.Location = new Point(0x41, 12);
            this.txtmabn.Name = "txtmabn";
            this.txtmabn.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtmabn.Properties.MaxLength = 10;
            this.txtmabn.Size = new Size(0x76, 20);
            this.txtmabn.TabIndex = 0;
            this.txtmabn.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label6.Font = new Font("Tahoma", 10f);
            this.label6.Location = new Point(0xc3, 13);
            this.label6.Name = "label6";
            this.label6.Size = new Size(70, 0x13);
            this.label6.TabIndex = 2;
            this.label6.Text = "Họ t\x00ean:";
            this.label6.TextAlign = ContentAlignment.TopRight;
            this.txthoten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txthoten.Location = new Point(0x106, 12);
            this.txthoten.Name = "txthoten";
            this.txthoten.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txthoten.Size = new Size(0x138, 20);
            this.txthoten.TabIndex = 1;
            this.txthoten.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label8.Font = new Font("Tahoma", 10f);
            this.label8.Location = new Point(11, 0x27);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x38, 0x13);
            this.label8.TabIndex = 2;
            this.label8.Text = "Ng\x00e0y:";
            this.label8.TextAlign = ContentAlignment.TopRight;
            this.datechidinh.EditValue = new DateTime(0x7dd, 11, 8, 2, 0x16, 9, 0x297);
            this.datechidinh.Location = new Point(0x41, 0x26);
            this.datechidinh.Name = "datechidinh";
            this.datechidinh.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.datechidinh.Properties.DisplayFormat.FormatString = "dd/MM/yyyy HH:mm";
            this.datechidinh.Properties.DisplayFormat.FormatType = FormatType.DateTime;
            this.datechidinh.Properties.EditFormat.FormatString = "dd/MM/yyyy HH:mm";
            this.datechidinh.Properties.EditFormat.FormatType = FormatType.DateTime;
            this.datechidinh.Properties.Mask.EditMask = "dd/MM/yyyy HH:mm";
            this.datechidinh.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.datechidinh.Size = new Size(0x76, 20);
            this.datechidinh.TabIndex = 3;
            this.ctrdanhsach_vp.ChieuRongTuDong = true;
            this.ctrdanhsach_vp.DanhSachCotHienThi = "";
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = "";
            this.ctrdanhsach_vp.Location = new Point(0x23d, 0x185);
            this.ctrdanhsach_vp.Name = "ctrdanhsach_vp";
            this.ctrdanhsach_vp.pRowsCountDown = 5;
            this.ctrdanhsach_vp.Size = new Size(60, 0x13);
            this.ctrdanhsach_vp.TabIndex = 8;
            this.ctrdanhsach_vp.Visible = false;
            this.ctrdanhsach_vp.Validated += new EventHandler(this.ctrdanhsach_vp_Validated);
            this.label9.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label9.Font = new Font("Tahoma", 10f);
            this.label9.Location = new Point(580, 13);
            this.label9.Name = "label9";
            this.label9.Size = new Size(0x5c, 0x13);
            this.label9.TabIndex = 2;
            this.label9.Text = "Khoa/Ph\x00f2ng:";
            this.label9.TextAlign = ContentAlignment.TopRight;
            this.cbbphong.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.cbbphong.Location = new Point(0x29c, 12);
            this.cbbphong.Name = "cbbphong";
            this.cbbphong.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbphong.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id"), new LookUpColumnInfo("ten", "T\x00ean ph\x00f2ng") });
            this.cbbphong.Size = new Size(160, 20);
            this.cbbphong.TabIndex = 2;
            this.label10.Font = new Font("Tahoma", 10f);
            this.label10.Location = new Point(0xb2, 0x27);
            this.label10.Name = "label10";
            this.label10.Size = new Size(0x57, 0x13);
            this.label10.TabIndex = 2;
            this.label10.Text = "Chẩn đo\x00e1n:";
            this.label10.TextAlign = ContentAlignment.TopRight;
            this.txtchandoan.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtchandoan.Location = new Point(0x106, 0x26);
            this.txtchandoan.Name = "txtchandoan";
            this.txtchandoan.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtchandoan.Size = new Size(0x138, 20);
            this.txtchandoan.TabIndex = 4;
            this.txtchandoan.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label11.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label11.Font = new Font("Tahoma", 10f);
            this.label11.Location = new Point(580, 0x27);
            this.label11.Name = "label11";
            this.label11.Size = new Size(0x5c, 0x13);
            this.label11.TabIndex = 2;
            this.label11.Text = "Người nhập:";
            this.label11.TextAlign = ContentAlignment.TopRight;
            this.txtnguoinhap.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.txtnguoinhap.Location = new Point(0x29c, 0x26);
            this.txtnguoinhap.Name = "txtnguoinhap";
            this.txtnguoinhap.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtnguoinhap.Size = new Size(160, 20);
            this.txtnguoinhap.TabIndex = 5;
            this.txtnguoinhap.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txttenhoatchat.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txttenhoatchat.Enabled = false;
            this.txttenhoatchat.Location = new Point(0x290, 0x143);
            this.txttenhoatchat.Name = "txttenhoatchat";
            this.txttenhoatchat.Size = new Size(0xac, 20);
            this.txttenhoatchat.TabIndex = 10;
            this.txttenhoatchat.TextChanged += new EventHandler(this.txtten_TextChanged);
            this.txttenhoatchat.Enter += new EventHandler(this.txtten_Enter);
            this.txttenhoatchat.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txttenhoatchat.Validated += new EventHandler(this.txtten_Validated);
            this.label2.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label2.Font = new Font("Tahoma", 10f);
            this.label2.Location = new Point(570, 0x144);
            this.label2.Name = "label2";
            this.label2.Size = new Size(90, 0x13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Hoạt chất:";
            this.label2.TextAlign = ContentAlignment.TopRight;
            this.label4.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label4.Font = new Font("Tahoma", 10f);
            this.label4.Location = new Point(0x6d, 0x10f);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x2b, 0x13);
            this.label4.TabIndex = 2;
            this.label4.Text = "Trưa:";
            this.label4.TextAlign = ContentAlignment.TopRight;
            this.label4.Visible = false;
            this.label7.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label7.Font = new Font("Tahoma", 10f);
            this.label7.Location = new Point(0xb0, 0x110);
            this.label7.Name = "label7";
            this.label7.Size = new Size(0x3b, 0x13);
            this.label7.TabIndex = 2;
            this.label7.Text = "Chiều:";
            this.label7.TextAlign = ContentAlignment.TopRight;
            this.label7.Visible = false;
            this.label12.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label12.Font = new Font("Tahoma", 10f);
            this.label12.Location = new Point(0x100, 0x110);
            this.label12.Name = "label12";
            this.label12.Size = new Size(0x2c, 0x13);
            this.label12.TabIndex = 2;
            this.label12.Text = "Tối:";
            this.label12.TextAlign = ContentAlignment.TopRight;
            this.label12.Visible = false;
            this.numsongay.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.numsongay.Location = new Point(0x27e, 0x15d);
            this.numsongay.Name = "numsongay";
            this.numsongay.Size = new Size(0x25, 0x15);
            this.numsongay.TabIndex = 13;
            int[] bits = new int[4];
            bits[0] = 1;
            this.numsongay.Value = new decimal(bits);
            this.numsongay.ValueChanged += new EventHandler(this.numsongay_ValueChanged);
            this.numsongay.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.numsongay.Validated += new EventHandler(this.numsongay_ValueChanged);
            this.label13.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label13.Font = new Font("Tahoma", 10f);
            this.label13.Location = new Point(570, 0x15f);
            this.label13.Name = "label13";
            this.label13.Size = new Size(0x47, 0x13);
            this.label13.TabIndex = 2;
            this.label13.Text = "Số ng\x00e0y:";
            this.label13.TextAlign = ContentAlignment.TopRight;
            this.label14.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label14.Font = new Font("Tahoma", 10f);
            this.label14.Location = new Point(0x2a3, 350);
            this.label14.Name = "label14";
            this.label14.Size = new Size(0x54, 0x13);
            this.label14.TabIndex = 2;
            this.label14.Text = "Số lượng:";
            this.label14.TextAlign = ContentAlignment.TopRight;
            this.label16.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label16.Font = new Font("Tahoma", 10f);
            this.label16.Location = new Point(-15, 0x15f);
            this.label16.Name = "label16";
            this.label16.Size = new Size(0x5d, 0x13);
            this.label16.TabIndex = 2;
            this.label16.Text = "C\x00e1ch d\x00f9ng:";
            this.label16.TextAlign = ContentAlignment.TopRight;
            this.txtcachdung.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtcachdung.EditValue = "";
            this.txtcachdung.Location = new Point(0x4a, 0x15d);
            this.txtcachdung.Name = "txtcachdung";
            this.txtcachdung.Size = new Size(0x1de, 20);
            this.txtcachdung.TabIndex = 11;
            this.txtcachdung.TextChanged += new EventHandler(this.txtcachdung_TextChanged);
            this.txtcachdung.Enter += new EventHandler(this.txtcachdung_Enter);
            this.txtcachdung.KeyDown += new KeyEventHandler(this.txtcachdung_KeyDown);
            this.tbnumslsang.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.tbnumslsang.BackColor = Color.White;
            this.tbnumslsang.DecimalBalance = 2;
            this.tbnumslsang.Location = new Point(0x4c, 0x10f);
            this.tbnumslsang.Name = "tbnumslsang";
            this.tbnumslsang.ReadOnly = false;
            this.tbnumslsang.Size = new Size(0x21, 20);
            this.tbnumslsang.SymbolDecimal = ",";
            this.tbnumslsang.SymbolThousand = ".";
            this.tbnumslsang.TabIndex = 10;
            this.tbnumslsang.Texts = "0";
            bits = new int[4];
            this.tbnumslsang.Values = new decimal(bits);
            this.tbnumslsang.Visible = false;
            this.tbnumslsang.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.tbnumslsang.Validated += new EventHandler(this.tbnumslsang_Validated);
            this.tbnumsltrua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.tbnumsltrua.BackColor = Color.White;
            this.tbnumsltrua.DecimalBalance = 2;
            this.tbnumsltrua.Location = new Point(0x95, 0x10f);
            this.tbnumsltrua.Name = "tbnumsltrua";
            this.tbnumsltrua.ReadOnly = false;
            this.tbnumsltrua.Size = new Size(0x21, 20);
            this.tbnumsltrua.SymbolDecimal = ",";
            this.tbnumsltrua.SymbolThousand = ".";
            this.tbnumsltrua.TabIndex = 11;
            this.tbnumsltrua.Texts = "0";
            bits = new int[4];
            this.tbnumsltrua.Values = new decimal(bits);
            this.tbnumsltrua.Visible = false;
            this.tbnumsltrua.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.tbnumsltrua.Validated += new EventHandler(this.tbnumslsang_Validated);
            this.tbnumslchieu.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.tbnumslchieu.BackColor = Color.White;
            this.tbnumslchieu.DecimalBalance = 2;
            this.tbnumslchieu.Location = new Point(0xe7, 0x10f);
            this.tbnumslchieu.Name = "tbnumslchieu";
            this.tbnumslchieu.ReadOnly = false;
            this.tbnumslchieu.Size = new Size(0x21, 20);
            this.tbnumslchieu.SymbolDecimal = ",";
            this.tbnumslchieu.SymbolThousand = ".";
            this.tbnumslchieu.TabIndex = 12;
            this.tbnumslchieu.Texts = "0";
            bits = new int[4];
            this.tbnumslchieu.Values = new decimal(bits);
            this.tbnumslchieu.Visible = false;
            this.tbnumslchieu.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.tbnumslchieu.Validated += new EventHandler(this.tbnumslsang_Validated);
            this.tbnumsltoi.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.tbnumsltoi.BackColor = Color.White;
            this.tbnumsltoi.DecimalBalance = 2;
            this.tbnumsltoi.Location = new Point(0x129, 0x10f);
            this.tbnumsltoi.Name = "tbnumsltoi";
            this.tbnumsltoi.ReadOnly = false;
            this.tbnumsltoi.Size = new Size(0x21, 20);
            this.tbnumsltoi.SymbolDecimal = ",";
            this.tbnumsltoi.SymbolThousand = ".";
            this.tbnumsltoi.TabIndex = 13;
            this.tbnumsltoi.Texts = "0";
            bits = new int[4];
            this.tbnumsltoi.Values = new decimal(bits);
            this.tbnumsltoi.Visible = false;
            this.tbnumsltoi.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.tbnumsltoi.Validated += new EventHandler(this.tbnumslsang_Validated);
            this.btnin.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnin.Image = Properties.Resources.imgprint;// (Image)manager.GetObject("btnin.Image");
            this.btnin.Location = new Point(0x1eb, 0x185);
            this.btnin.Name = "btnin";
            this.btnin.Size = new Size(0x3d, 0x17);
            this.btnin.TabIndex = 0x1a;
            this.btnin.Text = " &In";
            this.btnin.Click += new EventHandler(this.btnin_Click);
            this.btnhuy.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnhuy.Image = (Image) manager.GetObject("btnhuy.Image");
            this.btnhuy.Location = new Point(0x19d, 0x185);
            this.btnhuy.Name = "btnhuy";
            this.btnhuy.Size = new Size(0x4b, 0x17);
            this.btnhuy.TabIndex = 0x17;
            this.btnhuy.Text = " &Hủy [F7]";
            this.btnhuy.Click += new EventHandler(this.btnhuy_Click);
            this.label15.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label15.Font = new Font("Tahoma", 10f);
            this.label15.Location = new Point(0x197, 0x144);
            this.label15.Name = "label15";
            this.label15.Size = new Size(0x68, 0x13);
            this.label15.TabIndex = 2;
            this.label15.Text = "H\x00e0m lượng:";
            this.label15.TextAlign = ContentAlignment.TopRight;
            this.txthamluong.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txthamluong.EditValue = "";
            this.txthamluong.Enabled = false;
            this.txthamluong.Location = new Point(0x1fc, 0x143);
            this.txthamluong.Name = "txthamluong";
            this.txthamluong.Size = new Size(0x48, 20);
            this.txthamluong.TabIndex = 9;
            this.txthamluong.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.btnthemduocpham.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnthemduocpham.Location = new Point(0x194, 0x143);
            this.btnthemduocpham.Name = "btnthemduocpham";
            this.btnthemduocpham.Size = new Size(0x17, 20);
            this.btnthemduocpham.TabIndex = 0x2b;
            this.btnthemduocpham.Text = "...";
            this.btnthemduocpham.Click += new EventHandler(this.btnthemduocpham_Click);
            this.ctrdanhsach_cachdung.ChieuRongTuDong = true;
            this.ctrdanhsach_cachdung.DanhSachCotHienThi = "";
            this.ctrdanhsach_cachdung.DanhSachCotHienThi_kt = "";
            this.ctrdanhsach_cachdung.Location = new Point(0x290, 0x185);
            this.ctrdanhsach_cachdung.Name = "ctrdanhsach_cachdung";
            this.ctrdanhsach_cachdung.pRowsCountDown = 5;
            this.ctrdanhsach_cachdung.Size = new Size(60, 0x13);
            this.ctrdanhsach_cachdung.TabIndex = 12;
            this.ctrdanhsach_cachdung.Visible = false;
            this.ctrdanhsach_cachdung.Validated += new EventHandler(this.ctrdanhsach_cachdung_Validated);
            this.btnthemcachdung.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnthemcachdung.Location = new Point(0x228, 0x15d);
            this.btnthemcachdung.Name = "btnthemcachdung";
            this.btnthemcachdung.Size = new Size(0x17, 20);
            this.btnthemcachdung.TabIndex = 0x2c;
            this.btnthemcachdung.Text = "...";
            this.btnthemcachdung.Click += new EventHandler(this.btnthemcachdung_Click);
            this.txtsoluong.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtsoluong.Location = new Point(0x2f2, 0x15b);
            this.txtsoluong.Name = "txtsoluong";
            this.txtsoluong.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.txtsoluong.Properties.Appearance.Options.UseFont = true;
            this.txtsoluong.Properties.DisplayFormat.FormatString = "n2";
            this.txtsoluong.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txtsoluong.Properties.EditFormat.FormatString = "n2";
            this.txtsoluong.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txtsoluong.Properties.Mask.EditMask = "n2";
            this.txtsoluong.Properties.Mask.MaskType = MaskType.Numeric;
            this.txtsoluong.Size = new Size(0x1f, 0x16);
            this.txtsoluong.TabIndex = 14;
            this.txtsoluong.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.txtsoluong);
            base.Controls.Add(this.btnthemcachdung);
            base.Controls.Add(this.btnthemduocpham);
            base.Controls.Add(this.btnin);
            base.Controls.Add(this.numsongay);
            base.Controls.Add(this.ctrdanhsach_vp);
            base.Controls.Add(this.tbnumsltoi);
            base.Controls.Add(this.tbnumslchieu);
            base.Controls.Add(this.tbnumsltrua);
            base.Controls.Add(this.tbnumslsang);
            base.Controls.Add(this.cbbphong);
            base.Controls.Add(this.datechidinh);
            base.Controls.Add(this.txtnguoinhap);
            base.Controls.Add(this.txtchandoan);
            base.Controls.Add(this.txthoten);
            base.Controls.Add(this.txtmabn);
            base.Controls.Add(this.txtma);
            base.Controls.Add(this.gridds);
            base.Controls.Add(this.btnketthuc);
            base.Controls.Add(this.btnhuy);
            base.Controls.Add(this.btnxoa);
            base.Controls.Add(this.btnboqua);
            base.Controls.Add(this.btnsua);
            base.Controls.Add(this.btnluu);
            base.Controls.Add(this.btnmoi);
            base.Controls.Add(this.txttenhoatchat);
            base.Controls.Add(this.txtten);
            base.Controls.Add(this.label14);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.txthamluong);
            base.Controls.Add(this.txtcachdung);
            base.Controls.Add(this.ctrdanhsach_cachdung);
            base.Controls.Add(this.txtdvt);
            base.Controls.Add(this.label11);
            base.Controls.Add(this.label10);
            base.Controls.Add(this.label9);
            base.Controls.Add(this.label6);
            base.Controls.Add(this.label13);
            base.Controls.Add(this.label12);
            base.Controls.Add(this.label8);
            base.Controls.Add(this.label7);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.label15);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.label16);
            base.Controls.Add(this.label5);
            base.Controls.Add(this.lblmaso);
            base.Controls.Add(this.label2);
            base.Name = "ucbn_captoathuocmuangoai";
            base.Size = new Size(0x33f, 0x19f);
            base.Load += new EventHandler(this.ucDMSanPham_Load);
            base.ControlRemoved += new ControlEventHandler(this.ucbn_captoathuocmuangoai_ControlRemoved);
            base.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.repositoryItemTextEdit2.EndInit();
            this.txtma.Properties.EndInit();
            this.txtten.Properties.EndInit();
            this.txtdvt.Properties.EndInit();
            this.gridView1.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            this.gridds.EndInit();
            this.txtmabn.Properties.EndInit();
            this.txthoten.Properties.EndInit();
            this.datechidinh.Properties.VistaTimeProperties.EndInit();
            this.datechidinh.Properties.EndInit();
            this.cbbphong.Properties.EndInit();
            this.txtchandoan.Properties.EndInit();
            this.txtnguoinhap.Properties.EndInit();
            this.txttenhoatchat.Properties.EndInit();
            this.numsongay.EndInit();
            this.txtcachdung.Properties.EndInit();
            this.txthamluong.Properties.EndInit();
            this.txtsoluong.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void numsongay_ValueChanged(object sender, EventArgs e)
        {
            try
            {
                this.txtsoluong.EditValue = this.numsongay.Value * decimal.Parse(this.txtsoluong.Tag.ToString());
            }
            catch
            {
            }
        }

        private void tbnumslsang_Validated(object sender, EventArgs e)
        {
            try
            {
                this.txtsoluong.EditValue = (((this.tbnumslsang.Values + this.tbnumsltrua.Values) + this.tbnumslchieu.Values) + this.tbnumsltoi.Values) * this.numsongay.Value;
            }
            catch
            {
            }
        }

        private void txtcachdung_Enter(object sender, EventArgs e)
        {
            this.ctrdanhsach_cachdung.Width = this.txtcachdung.Width;
            this.ctrdanhsach_cachdung.DanhSachCotHienThi_kt = (this.txtcachdung.Width - 0x35) + "," + 50;
            this.ctrdanhsach_cachdung.Height = 90;
            this.ctrdanhsach_cachdung.Location = new Point(this.txtcachdung.Location.X, (this.txtcachdung.Location.Y - 1) - this.ctrdanhsach_cachdung.Height);
            this.ctrdanhsach_cachdung.BringToFront();
        }

        private void txtcachdung_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))
            {
                if (this.ctrdanhsach_cachdung.Visible)
                {
                    this.ctrdanhsach_cachdung.Focus();
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.ctrdanhsach_cachdung.Visible = false;
            }
            else
            {
                this.ctrdanhsach_cachdung.Visible = false;
                this.ucDMSanPham_KeyDown(sender, e);
            }
        }

        private void txtcachdung_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.txtcachdung.IsEditorActive)
                {
                    this.ctrdanhsach_cachdung.Visible = true;
                    this.ctrdanhsach_cachdung.Locdulieu(this.txtcachdung.Text);
                }
            }
            catch
            {
            }
        }

        private void txtma_Validated(object sender, EventArgs e)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("ma='" + this.txtma.Text + "'");
                this.f_SetControl_dmsanpham(long.Parse(rowArray[0]["id"].ToString()));
                if (rowArray.Length > 0)
                {
                    this.ctrdanhsach_vp.Visible = false;
                    this.tbnumslsang.Focus();
                }
            }
            catch
            {
            }
        }

        private void txtten_Enter(object sender, EventArgs e)
        {
            this.ctrdanhsach_vp.Width = (this.txttenhoatchat.Location.X + this.txttenhoatchat.Width) - this.txtma.Location.X;
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = string.Concat(new object[] { this.txtten.Location.X - this.txtma.Location.X, ",", ((this.ctrdanhsach_vp.Width - 0x23) - this.txtten.Location.X) + this.txtma.Location.X, ",", 30 });
            this.ctrdanhsach_vp.Location = new Point(this.txtma.Location.X, (this.txtma.Location.Y - this.ctrdanhsach_vp.Height) - 1);
            this.ctrdanhsach_vp.BringToFront();
        }

        private void txtten_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))
            {
                if (this.ctrdanhsach_vp.Visible)
                {
                    this.ctrdanhsach_vp.Focus();
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.ctrdanhsach_vp.Visible = false;
            }
            else
            {
                this.ctrdanhsach_vp.Visible = false;
                this.ucDMSanPham_KeyDown(sender, e);
            }
        }

        private void txtten_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.txtten.IsEditorActive)
                {
                    this.ctrdanhsach_vp.Visible = true;
                    this.ctrdanhsach_vp.Locdulieu(this.txtten.Text);
                }
            }
            catch
            {
            }
        }

        private void txtten_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void ucbn_captoathuocmuangoai_ControlRemoved(object sender, ControlEventArgs e)
        {
            if (e.Control.Name == "ucd_dmduocpham")
            {
                this.f_Loaddata_dmduocpham();
            }
            else if (e.Control.Name == "ucd_dmcachdung")
            {
                this.f_Loaddata_cachdung();
            }
        }

        private void ucDMSanPham_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
            else if (e.KeyCode == Keys.F2)
            {
                if (this.btnmoi.Enabled)
                {
                    this.btnmoi_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F3)
            {
                if (this.btnsua.Enabled)
                {
                    this.btnsua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F4)
            {
                if (this.btnboqua.Enabled)
                {
                    this.btnboqua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F5)
            {
                if (this.btnluu.Enabled)
                {
                    this.btnluu_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F7)
            {
                if (this.btnxoa.Enabled)
                {
                    this.btnxoa_Click(null, null);
                }
            }
            else if ((e.KeyCode == Keys.F12) && this.btnketthuc.Enabled)
            {
                this.btnketthuc_Click(null, null);
            }
        }

        private void ucDMSanPham_Load(object sender, EventArgs e)
        {
            this._toathuoc = new DToaThuoc(this._xuli.pConFigData);
            this.f_load_khoaphong();
            this.f_Loaddata_dmduocpham();
            this.f_Loaddata_cachdung();
            this.f_setcontrol_toathuoc(this._idql);
            if (this.txthoten.Tag.ToString() == "0")
            {
                this.f_loadData_thongtinloaibn(this._loaibn);
            }
            this.f_loaddata_toathuocct(long.Parse(this.txthoten.Tag.ToString()));
            this.btnboqua_Click(null, null);
            this.f_loadinfo_chidinhchitiet(0);
            if (this.txthoten.Tag.ToString() == "0")
            {
                this.btnsua_Click(null, null);
            }
            this.txtmabn.Properties.ReadOnly = this.txthoten.Properties.ReadOnly = this.txtnguoinhap.Properties.ReadOnly = this.datechidinh.Properties.ReadOnly = this.cbbphong.Properties.ReadOnly = this.txtchandoan.Properties.ReadOnly = true;
        }
    }
}

